Delphi 1.0

The following is our complete original review of Delphi 1.0.

Back to Delphi Installation

Borland's Delphi is a visual programming systems aimed at rapid application development. Huw Collingbourne finds out if it is on the right track.

Visual development systems are all the rage these days. Whether you just want to program a simple calculator or a sophisticated database, there are now plenty of determinedly 'visual' tools for the job. The latest arrival on the scene is Borland's Delphi.

Predictably, the system claims to have some of the best visual design tools around. But just in case that isn't enough to persuade you of its merits, it also has lots of extra goodies too. Unlike Visual Basic, for example, it is a true compiler so it can be used to create fast, standalone applications. And it has built-in database functionality which could puts it into competition with the likes of Microsoft Access and Lotus Approach.

Borland's Delphi is an ambitious product. Not only does it provide visual tools for drag-and-drop application development with or without database access, but it also incorporates a powerful object-orientated version of the Pascal language for a more traditional style of programming. Meanwhile, an enhanced version of Delphi is available for users who need to develop client/server applications.

All this should, in theory, make Delphi a supremely flexible system suitable for developers at all levels. On the other hand, there is the obvious risk that Borland might have over-reached itself. It wouldn't be the first time in the company's history.

Here we've taken a close look at Delphi in an attempt to find out whether it really is all that Borland would have us believe...

Delphi

If you were to believe all of Borland's claims, you would probably conclude that Delphi is nothing less than a revolutionary product. Yet when you actually run Delphi, you'll see that it looks surprisingly familiar. In fact, for Visual Basic (VB) programmers this may be less a case of familiarity than déja vu.

The Delphi environment takes the form of several free-floating palettes with a blank window or 'form' at the centre of the screen. As in VB, the application design process typically begins by picking some components such as buttons and fields from a palette and dropping them onto the form. You can then adjust their appearance and behaviour by setting 'properties' listed in a box called the Object Inspector.

To be fair, this isn't a slavish copy of the VB environment. As you'll soon discover, Delphi has made a number of improvements. The most obvious of these is the division of the component palette into tabbed pages each of which contains a set of related items such as dialog boxes or data controls.

The handling of events such as key presses and mouse clicks is also slightly different. In Visual Basic, when you select an object such as a button or text-entry field, you cursor is placed into an editing window where you can pick an event from a drop-down list. This has the effect of placing your cursor inside an empty subroutine which will be triggered whenever the selected event occurs.

In Delphi, the events are all listed on a second page in the Object Inspector window. Only when you double click the event name is your cursor placed into the editor. The Delphi editor, incidentally, lists all code sequentially, whereas VB displays one procedure at a time. The VB editor and event-list is probably marginally more friendly when entering small pieces of code to automate a form. However, when writing long programs, the Delphi editor and event palette is much more convenient.

Another simple but useful feature of Delphi programming is the synchronisation of visual design with the underlying code representation. In VB, if you enter a subroutine for an object called Button1 and subsequently rename that object ExitButton, you will end up detaching your code from the associated object. But in Delphi, when you rename an object, the new name is automatically substituted for the old wherever it occurs in your code, which is altogether a more civilised arrangement.

Pick'n'mix

Delphi comes as standard with an impressive range of drag-and-drop components. In addition to the inevitable text-entry fields, buttons, list-boxes, scroll-bars and similar objects for designing windows and dialog boxes, there are also some more specialised visual components such as tabbed-dialog boxes and collapsible outlines. You can also import Visual Basic VBX controls and use them as though they were native Delphi objects.

Delphi has some non-visual components too, including data exchange tools which implement DDE (Dynamic Data Exchange) and OLE 2 (Object Linking and Embedding), These allow your Delphi programs simply to embed text or graphic data from some other OLE 2 application and edit it using the features and menu systems of that application. For example, an OLE 2 control would let you embed data from an Excel spreadsheet in such a way that your Delphi application would inherit Excel's mathematical and charting functionality.

Two of the pages on the component palette are devoted to database tools. These include components for loading and querying data, navigating through the records in a table and displaying memo fields or graphics.

Building a database using Delphi is not much different from building any other kind of application. You just pick the appropriate components from the palette, drop them onto a form and connect them up by setting properties in the Object Inspector. You can also connect a data file on disk by entering its name as a property.

A simple record-browsing database can be built from just three components - a data table object which interfaces with the data on disk, a data source object which channels the data from the table object to any number of other data-aware objects, and a grid in which records can be displayed in tabular format.

Once you've added these three components, the data file can be activated so that its data is displayed on the form during the design process. This allows you to check that the data is valid and all the data-display components such as tables, memos and pictures are functioning as intended.

General selection

If you want to process the data in some way, all you have to do is to substitute the table object with a query object. This lets you enter an SQL statement to instruct the object to manipulate the data, say by filtering out a subset of records or sorting them into a different order, prior to distributing them to other controls on the form.

By sticking to visual design techniques, you can create a fully functioning database application without entering any Object Pascal code. If you want to get a bit clever, though, it takes only a little programming to automate the application further. You could, for example, add some code to execute queries when different buttons are pressed. Let's suppose that you have a database of employees and you want a button that retrieves records of the high earners. All you have to do is add the following lines to the button's OnClick event-handling procedure:

Query1.SQL.Add('SELECT * FROM employees WHERE Salary < 30000 ORDER BY Surname')

Query1.Open;

When the button is clicked, the query will select all those records in which the salary is in excess of 30,000 and it will then sort them alphabetically by surname. A grid linked to the query object would display the selected and sorted records.

If you can't be bothered going to the trouble of designing a data form, there is even a Database Form Expert which generates simple forms from tables or queries and automatically adds a set of record navigation buttons.

The desktop version of Delphi supports dBase and Paradox databases. Corporate users who want to build client/server applications will need the enhanced version of Delphi which includes support for the major database servers, Oracle, Sybase and Informix, plus Borland's own database server, Interbase. It also has an ODBC (Open DataBase Connectivity) driver which enables you to connect to a much broader range of data sources, albeit without the same degree of efficiency as the dedicated drivers.

Both editions of Delphi include a local Interbase server which provides programmers with the necessary tools to do 'off-line' development, so that you can test many aspects of a client/server applications even when you are not connected to a network. Delphi also comes with a number of other tools to assist in database development. Notable among these are the Database Desktop and the ReportSmith reporting program.

The Database Desktop is a standalone relational database system which can either load existing files in Paradox or dBase format or it can be used to create new files and enter data into them. Although it doesn't have the full set of features you'll find in a top-quality relational database, it can nevertheless be used for many common data management tasks. It can search for or sort records, it can restructure a table and it can filter out subsets of records which match criteria entered into a QBE (Query By Example) grid.

ReportSmith is another application which can be independently of the core Delphi environment. It can be used to layout reports using data contained in files saved by PC applications such as Excel and Access. In the version of ReportSmith supplied with Delphi client/server, it can also make use of data supplied by servers.

ReportSmith can generate fairly sophisticated report layouts and it even has a drag-and-drop facility to let you cross-tabulate data in much the same way as the pivot-tables supplied in many spreadsheets. To simplify the process of accessing ReportSmith direct from a Delphi application, there is also a visual ReportSmith component which can be placed onto a form.

A class act

Although you can get a long way in Delphi development without doing any programming, in all but the most trivial of applications there will inevitably come a point at which some programming will be inevitable.

If you have any programming experience at all, this shouldn't prove to be too much of a problem. The Object Pascal language is a descendant of Turbo Pascal and anyone who has used one of Borland's previous Pascal compilers should be completely at home with it. Basic programmers shouldn't find it too hard to pick up the essentials of the language either, though the concept of object orientation may take a bit of getting used to. Even C and C++ programmers (many of whom instinctively despise Pascal), may find themselves pleasantly surprised. Object Pascal now has a great deal in common with C++, including low-level programming features, good exception handling, modularity and, of course, objects.

An object in Object Pascal is essentially a special type of user-defined record. Unlike ordinary records, objects include the procedures or 'methods' which operate upon the object's internal data. Strictly speaking, an object only comes into being when it is initialised. Its type definition is said to be a Class.

Hierarchies of classes can be defined such that descendent class B inherits all the features of ancestor class, A, but alters existing behaviour by inserting new methods or 'overriding' those of the ancestor class.

For instance, you could have one class type called TCalc, which defines a simple calculator that does additions and subtractions. If you want to create a more sophisticated calculator which also does multiplication and subtraction, you could inherit the existing capabilities of the TCalc class by declaring a new TSuperCalc class as follows:

TSuperCalc = class(TCalc)

You would then add two new methods, Multiply and Subtract. You don't need to worry about methods for addition and subtraction since these already exist in the ancestor TCalc class.

If you feel unhappy with object orientated programming, the good news is that you can ignore it to a considerable extent and stick to programming in a more traditional fashion. However, you will need to be fairly happy with classes and objects if you are to take advantage of one of the most interesting and powerful features of Delphi programming - namely, component writing.

Unlike Visual Basic, Delphi provides everything you need to create new drag-and-drop components which can be added to one of the pages of its palette. It even has a tool called the Component Expert which lets you pick an existing component from which to derive a new one. A new component can be derived from a simple or a complex type. When you derive a component from a very simple type, you will need to program almost all of its behaviour. When you derive one from a complex type, such as a tabbed notebook component, you would only need to program any changes or additions. You can even derive components from Visual Basic VBX controls, which is a neat trick given that Visual Basic itself can't do this!

User-defined components have exactly the same status in the Delphi environment as the default components. They come with their own set of events and properties which can be manipulated in the Object Inspector. Properties are added to components by declaring a variable within the component class definition plus two methods to read and write values to and from the variable.

Secure units

Other important features of the language include support for open array parameters of mixed types, the addition of Class methods which operate on the class itself rather than on an instantiated object and a completely new exception-handling technique to help create robust applications, .

Exceptions are handled in their own unit, which is available as source code. There are also many other units providing a broad range of ready-coded routines to simplify file operations, mathematics, string manipulation and so on.

Among the programming tasks simplified by the routines within these units is list-handling. Lists are very flexible and valuable data structures which link together objects by pointing to precise locations in the computer's memory. However, programmers who are unfamiliar with these list operations - and many Visual Basic programmers will be - can easily run into serious problems by accidentally pointing at memory which is already in use.

Delphi's list-handling procedures take care of the nitty-gritty of adding, deleting and inserting list items in a safe manner. It also implements a special type of list called a StringList. Each item in a string list is composed of a pair of objects, one of which is a string, the other one being an object of any type. This is particularly useful if you want to operate on lists with some visual representation. Borland gives, as an example, a multi-page file manager in which a new page is added for every drive on your PC. Each string object in the list contains the name of a drive - such as 'C:\;', whereas the associated object contains a bitmap picture representing a floppy disk, hard disk or network drive, as appropriate. When you click a tab to change drive, the string item automatically brings with it the associated bitmap and both are displayed alongside one another on the tab.

In fact, StringLists are much more flexible structures than this example suggests. After all, there is no reason why the objects paired with each string should not themselves be StringLists, thereby allowing you to create linked networks of great complexity without requiring any explicit pointer operations.

Easy does it

Even though visual programming itself implies an essential simplification of the application design process, this has not been sufficient to satisfy the designers of Delphi. Accordingly, there are numerous other ease-of-use features built into the system.

For example, when you start work on a project or want to add a new window to an existing project you can optionally pick a ready-to-use form from a gallery. The gallery includes a multi-page dialog, an About box, a password dialog and a tabbed notebook dialog. You can also design your own forms and add them to the gallery to be re-used at a later date.

Learning Delphi is made as painless as possible by the provision of context-sensitive help and on-line tutorials to guide you through the early stages of creating a user interface or a database application. There are also five volumes of printed documentation (eight with Delphi client/server) with separate manuals devoted to application programming, database development, component writing, the local InterBase server and ReportSmith. It has to be said that the documentation is printed on much flimsier paper than any previous Borland release we've seen, which is possibly indicative of Borland's recent cost-cutting efforts.

Delphi can also be supplied on floppy disk, by the way, but only by ordering them direct from Borland.

Curiously, there is no reference guide to the Object Pascal language, though Borland can supply one at an additional cost. The language is comprehensively described in on-line help, however. Moreover, when working in the editor, you can search for help by clicking a Pascal reserved word or expression and selecting 'Topic Search' from a popup mouse menu.

The same mouse menu also provides options for debugging a program. For example, it lets you add a breakpoint to stop program execution at the current line, evaluate a selected expression or add a variable to be monitored in a Watch window.

Delphi's debugging is fully windows hosted and it lets you execute your code by stepping through it one line at a time in the editor window. Other debugging tools include WinSpector, to help track General Protection Faults and an object browser which displays the hierarchical relationships of objects complete with their procedures and variables. A window pane lists any references to objects in your program and it lets you jump straight to these references in the editor.

The editor itself rather good. It has multi-level undo and redo, syntax-sensitive colour highlighting and an optional 'regular expression' text-searching facility modelled on the BRIEF editor. In fact, programmers used to BRIEF can also instruct the Delphi editor to respond to the same keystrokes as BRIEF. Alternatively, you could substitute the keystrokes used by the Epsilon editor or those used by older Borland products.

PC Plus verdict

Borland has been going through a difficult period over the past couple of years. Since the acquisition of Ashton-Tate - which brought Borland a huge range of business software including dBase and Interbase - the company has seemed to be distinctly over-stretched.

Unfortunately, Borland's programming software, which at one time virtually set the standards of excellence, has suffered as a result. Its C++ compiler has lost ground to Microsoft Visual C++ and you could be forgiven for thinking the company had forgotten all about its Pascal compiler which was last updated about three years ago. Delphi, therefore, has come as a pleasant surprise.

Although it undoubtedly owes a debt to Microsoft's Visual Basic, Delphi is a lot more than simply a copy-cat Visual Pascal. Its blend of visual programming techniques with a fully object-orientated programming language is both powerful and elegant. Frankly, it is so far ahead of Visual Basic 3.0 that it is hard to think of any justification, other than habit, for continuing to use the Microsoft product.

Delphi has numerous advantages over VB. Of these, probably the single most significant is its compilation to native machine code. This not only greatly increases the speed of program execution but also allows developers to generate DLLs (Dynamic Link Libraries) or VBXs (Visual Basic Controls). Delphi also scores over VB by enabling programmers to develop new Delphi visual components without having to make the traumatic switch to a C++ compiler.

Delphi's database programming controls and, in the client/server version, dedicated support for server databases, also makes it a strong challenger to PowerBuilder.

Microsoft will no doubt hope to out-Delphi Delphi with the forthcoming release of Visual Basic 4. But for the time being at least, Borland has, quite simply, the best visual development product available.

Client/Server Development

In recent months, it has seemed that almost every major PC software company wants to grab a share of the client/server market. Delphi client/server faces competition from products as diverse as Clarion for Windows, Intersolv's Q+E 6 which lets you query data without explicitly using SQL to Novell's Visual AppWare, which lets you build complete applications without programming.

However, the product which, to date, has set the standards for client/server development is PowerSoft's PowerBuilder. This is a visual programming system which uses some object -orientated techniques and provides support for local PC data sources such as Paradox and Excel in addition to server databases such as Sybase and Oracle. It has several limitations, however, the most problematical of which is its lack of native-code compilation. This means it cannot compile fast standalone executable applications or shared DLLs (Dynamic Link Libraries). Borland has also criticised PowerBuilder for its lack of robustness. It does not have inbuilt error-recovery to compare with Delphi's Exception objects.

Nevertheless, PowerBuilder is so well established as a tool for client/server development that any potential rival will certainly face difficulties in persuading existing users to make the switch. The prospects for Delphi, however, look very promising.

Delphi Exceptions

Programs which unexpectedly go wrong are, at best, a nuisance, at worst, a disaster. Delphi addresses the problem of run-time program errors or 'exceptions' with a neat, object-orientated exception handler.

Exceptions come in many forms. For instance, if a user enters an inappropriate value into a calculator field, a 'Divide By Zero' exception may be raised. Similarly, exceptions will be raised if your program tries to allocate more memory than is currently available or tries to save a file to a disk which is already full. While the programmer may attempt to code around all these possibilities using endless CASE or IF THEN/ELSE statements, there is inevitably the risk that some unforeseen hazard will slip through the net with catastrophic results. For this reason, Delphi lets you 'protect' blocks of code such that, if an exception is generated, it should normally be possible to recover from it.

You can test for each possible type of error using statements such as on EDivByZero. However, better still, you can declare an temporary variable to hold the exception using the syntax E:Exception, where E is the name of the variable and Exception is its class type. Exceptions are returned as initialised objects and can be manipulated in the same way as any other object. You can access the exception's internal data, for example, including a message which identifies the nature of the error. The following code fragment shows how we can extract the message from an exception object and display it to the user. Assume here, that a value for the variable, MyVal, has been entered into a field at run time.

procedure TForm1.Button1Click(Sender: TObject);

var

  RealResult : Real;

  StrResult : String;

begin

try

  RealResult := 1.11 / MyVal;

  Str(RealResult:2:2, StrResult);

  Edit2.Text := StrResult;

except

  on E:Exception do

  begin

  RealResult := 0;

  MessageDlg('Error! ' + E.Message + '!',

  mtInformation, [mbOK], 0);

  end;

end;

end;

The code between the words 'try' and 'except' is protected. If the variable, MyVal, has the value 0.0, an exception is raised and is handled by the code starting 'on E:Exception do'. The variable, RealResult, will now be set to zero and a message will be displayed stating: "Error! Floating point division by zero!'

 PC Plus PRODUCT FACTS

Product

Delphi

Price

£349 / £999 client/server edition plus VAT

From

Borland, (01734) 320022

For

State-of-the-art visual design

 

Powerful object orientated language

Against

No printed language reference

Range of Features

10/10

Overall Speed

10/10

Ease of Use

9/10

Documentation

6/10

PC Plus Value Verdict

10/10 PC Plus Gold Award

Back to Delphi Installation